package com.molichuxing.services.infrastructure.dao;

import com.molichuxing.framework.dao.RootMapper;
import com.molichuxing.services.infrastructure.bean.GoodsDealerBean;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 商品分销表 Mapper 接口
 * </p>
 *
 * @author xuelin yi
 * @since 2019-08-12
 */
public interface GoodsDealerMapper extends RootMapper<GoodsDealerBean> {

    /**
     * 设置商品和经销商的分销状态
     * @param goodsId
     * @param dealerId
     * @param status
     * @return
     */
    public int settingGoodsDistribution(@Param("goodsId") int goodsId, @Param("dealerId") int dealerId, @Param("status") Integer status);

    /**
     * 根据条件分页查询count
     * @param goodsId
     * @param dealerIds
     * @param status
     * @return
     */
    public int getDealerPageCount(@Param("goodsId") int goodsId, @Param("dealerIds") List<Integer> dealerIds, @Param("status") Integer status);

    /**
     * 新增分销商和商品关系
     * @param goodsDealerBean
     * @return
     */
    @Override
    public int create(GoodsDealerBean goodsDealerBean);

    /**
     * 删除分销商和商品关系
     * @param goodsId
     * @return
     */
    public int delete(@Param("goodsId") int goodsId);


    /**
     * 删除分销商和商品关系
     * @param dealerId
     * @return
     */
    public int deleteByDealerId(@Param("dealerId") int dealerId);

    /**
     * 删除分销商和商品关系
     * @param dealerId
     * @return
     */
    public int deleteDealerRelation(@Param("dealerId") int dealerId, @Param("goodsIds") List<Integer> goodsIds);

    /**
     * 根据条件分页查询结果
     * @param goodsId
     * @param dealerIds
     * @param status
     * @return
     */
    public List<GoodsDealerBean> getDealerPage(@Param("goodsId") int goodsId, @Param("dealerIds") List<Integer> dealerIds, @Param("status") Integer status,
                                               @Param("pageNum")int pageNum, @Param("pageSize") int pageSize);

    /**
     * 根据条件查询结果
     * @param goodsId
     * @param dealerIds
     * @param status
     * @return
     */
    public List<GoodsDealerBean> getDealerList(@Param("goodsId") Integer goodsId, @Param("dealerIds") List<Integer> dealerIds, @Param("status") Integer status);


    /**
     * 根据商品ID查询分销商数量
     * @param goodsId
     * @return
     */
    public int getDealerCountByGoodsId(@Param("goodsId") int goodsId);

    /**
     * 查询经销商下商品数量
     * @param goodsIds
     * @param dealerId
     * @return
     */
    public int getGoodsCount(@Param("goodsIds") List<Integer> goodsIds, @Param("dealerId") Integer dealerId);
}
